home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / snmp_0_1.zip / snmp-0.1 / aka / gui / SnmpTableListener.java < prev   
Text File  |  1997-06-09  |  3KB  |  127 lines

  1. /*
  2. Snmp Library
  3. Copyright (C) 1997 Alex Kowalenko Associates Pty Ltd. All rights reserved.
  4.  
  5. This software maybe be free distributed, any any form, without fee, 
  6. but may not be modified in any way without express permission of 
  7. the directors of Alex Kowalenko Associates Pty Ltd. 
  8.  
  9. Alex Kowalenko Associates Pty Ltd makes no representations or
  10. warranties about the suitabililty of the software, not even the
  11. implied warranty of merchantability or fitness for any particular
  12. purpose.    
  13. */
  14.  
  15. /**
  16.  * Class Description
  17.  * @see 
  18.  * @version     $Id: SnmpTableListener.java,v 1.3 1997/05/30 11:50:39 alex Exp $
  19.  * @author      Alex Kowalenko
  20.  */
  21.  
  22. package aka.gui;
  23.  
  24. import java.awt.*;
  25. import java.awt.event.*;
  26.  
  27. class SnmpTableListener implements ActionListener, WindowListener {
  28.  
  29.     static final int MENU_FILE_QUIT = 1;
  30.     static final int MENU_EDIT_ADDVAR = 2;
  31.     static final int MENU_EDIT_DELVAR = 9;
  32.     static final int MENU_EDIT_SETPOLL = 3;
  33.     static final int MENU_EDIT_SETCN = 4;
  34.     static final int GET_VARIABLE = 5;
  35.     static final int GET_POLLING = 6;
  36.     static final int GET_COMMUNITY = 7;
  37.     static final int GET_HOSTNAME = 8;
  38.     
  39.     int _id;
  40.     SnmpTable _app;
  41.     SnmpTableGui _gui;
  42.     Window _window = null;
  43.  
  44.   public SnmpTableListener(SnmpTable app, SnmpTableGui gui) {
  45.       _app = app;
  46.       _gui = gui;
  47.       _id = 0;
  48.   };
  49.  
  50.   public SnmpTableListener(int id, SnmpTable app, SnmpTableGui gui) {
  51.       _id = id;
  52.       _app = app;
  53.       _gui = gui;
  54.   };
  55.  
  56.   public SnmpTableListener(int id, SnmpTable app, Window window) {
  57.       _id = id;
  58.       _app = app;
  59.       _window = window;
  60.   };
  61.  
  62. /**
  63.  * 
  64.  */
  65.   public void actionPerformed(ActionEvent e) {
  66.       switch(_id) {
  67.     case MENU_FILE_QUIT :
  68.       _app.quit();
  69.       System.exit(0);
  70.       break;
  71.     case MENU_EDIT_ADDVAR:
  72.       _gui.doDialog("Add Variable", "Add new Variable", GET_VARIABLE);
  73.       break;    
  74.  
  75.     case MENU_EDIT_DELVAR:
  76.       String name = _gui.getSelected();
  77.       if(name != null) {
  78.           _app.deleteVariable(name);
  79.       };
  80.       break;    
  81.  
  82.     case MENU_EDIT_SETPOLL:
  83.       _gui.doDialog("Polling Interval", "Set Polling Interval", GET_POLLING);
  84.       break;
  85.     case MENU_EDIT_SETCN:
  86.       _gui.doDialog("Community Name", "Set Community Name", GET_COMMUNITY);
  87.       break;
  88.  
  89.     case GET_VARIABLE:
  90.       _app.addVariable(_gui.getDialogString());
  91.       break;
  92.  
  93.     case GET_POLLING:
  94.        _app.setPollingInterval(Integer.parseInt(_gui.getDialogString()));
  95.        break;
  96.        
  97.     case GET_COMMUNITY:
  98.       _app.setCommunityName(_gui.getDialogString());
  99.       break;
  100.  
  101.     case GET_HOSTNAME:
  102.       System.out.println("Hostname =" + _gui.getHostName() + ".");
  103.       _app.setHost(_gui.getHostName());
  104.       break;
  105.  
  106.       };
  107.   };
  108.  
  109.   public void windowOpened(WindowEvent e) {};
  110.   public void windowClosing(WindowEvent e) {
  111.       if(_window != null) {
  112.       _window.dispose();
  113.       }
  114.       else {
  115.       _app.quit();
  116.       System.exit(0);
  117.       };
  118.   };
  119.   public void windowClosed(WindowEvent e) {};
  120.   public void windowIconified(WindowEvent e) {};
  121.   public void windowDeiconified(WindowEvent e) {};
  122.   public void windowActivated(WindowEvent e) {};  
  123.   public void windowDeactivated(WindowEvent e) {};
  124.  
  125. };
  126.  
  127.